﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using eTerm.PlugIn.NCore;

namespace eTerm.MsSql.DbProvider
{
    public sealed class MsSqlDbLogProvider
    {
        private static readonly MsSqlDbLogProvider __log = new MsSqlDbLogProvider();

        private MsSqlDbLogProvider()
        { 
        
        }

        public static MsSqlDbLogProvider Instance
        {
            get {
                return __log;
            }
        }

        public void WRITELOG(int eventType, string logger, string description) {
            new SysDbLog() { 
             Description = description,
              LogDate = DateTime.Now,
               Logger = logger ,
                LogType = eventType
            }.Save();
        }

        public void WRITELOG(int eventType, IPlugIn plugIn, string description) {
            this.WRITELOG(eventType, plugIn.GetType().FullName, description);
        }

        public void DEBUG(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.DEBUG, plugIn, description);
        }


        public void INFO(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.INFO, plugIn, description);
        }


        public void ERROR(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.ERROR, plugIn, description);
        }


        public void INSTRUCT(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.INSTRUCT, plugIn, description);
        }

        public void WARNING(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.WARNING, plugIn, description);
        }

        public void SUCCESS(IPlugIn plugIn, string description)
        {
            WRITELOG((int)EventType.SUCCESS, plugIn, description);
        }

    }
}
